﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using FRL.DebtChased.Website;

namespace FRL.DebtChased.Website.ClientZone
{

	/// <summary>
	/// Declaration of ClientMaster class
	/// </summary>
	public partial class ClientMaster : System.Web.UI.MasterPage
	{

		/////////////////////////////////////////////////////////////
		// Attributes

		private MySession m_mySession = null;

		public bool m_bShowError = false;
		public string ErrorMessage
		{
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					this.lbErrors.Text = null;
					m_bShowError = false;
				}
				else
				{
					this.lbErrors.Text = value;
					m_bShowError = true;
				}
			}
		}

		/////////////////////////////////////////////////////////////
		// Event handlers

		protected void Page_Load(object sender, EventArgs e)
		{

			// If this is a postback...
			if (this.IsPostBack)
			{


			}
			else
			{

				// Inform the session of the page that is being loaded
				if (m_mySession == null)
					m_mySession = MySession.BindMySession();
				m_mySession.LoadingPage(this.Page.AppRelativeVirtualPath);

				// Set panel colours
				MyApplication myApp = MyApplication.BindMyApplication();
				pnlLogoBox.BackColor = myApp.PrimaryWebColor;

				// Set menu colors
				clientMainMenu.ForeColor = myApp.PrimaryWebColor;
				clientMainMenu.DynamicHoverStyle.ForeColor = myApp.SecondaryWebColor;
				clientMainMenu.DynamicHoverStyle.BackColor = System.Drawing.Color.White;
				clientMainMenu.DynamicMenuStyle.BackColor = myApp.PrimaryWebColor;
				clientMainMenu.DynamicMenuItemStyle.ForeColor = System.Drawing.Color.White;
				clientMainMenu.StaticHoverStyle.ForeColor = myApp.SecondaryWebColor;

				// Set menu colors - border colours
				clientMainMenu.StaticSelectedStyle.BorderColor = myApp.SecondaryWebColor;
				clientMainMenu.DynamicSelectedStyle.BorderColor = myApp.SecondaryWebColor;

			}

		}

		protected void ClientMainMenu_MenuItemDataBound(object sender, MenuEventArgs e)
		{
#if DEBUG
			if (m_mySession == null)
				return;
#endif // #if DEBUG

			// For clients, hide the search and admin options
			if (e.Item.Text == "Admin")
			{
				clientMainMenu.Items.Remove(e.Item);
			}

		}

	}

}